<template>
  <div class="parking_ticket">
    <el-tabs v-model="activeName" style="height: 100%;" @tab-click="handleClick">
      <el-tab-pane label="停车券规则" name="first">
        <TicketRule />
      </el-tab-pane>
      <el-tab-pane style="height: 100%;" label="商户停车券" name="second">
        <ShopTicket ref="secondMethod" />
      </el-tab-pane>
      <el-tab-pane style="height: 100%;" label="平台停车券" name="third">
        <UserTicket ref="thirdMethod"/>
      </el-tab-pane>
      <el-tab-pane style="height: 100%;" label="注册发放停车券" name="fourth">
        <Automatic ref="fourthMethod"/>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
  import TicketRule from './components/ticketRule.vue'
  import ShopTicket from './components/shopTicket.vue'
  import UserTicket from './components/userTicket.vue'
  import Automatic from './components/automaticGrant.vue'

  export default {
    components: { TicketRule, ShopTicket, UserTicket, Automatic },
    data() {
      return {
        activeName: 'first'
      }
    },

    mounted() {
      if(location.hash.split("#")[2] != null){
        this.activeName = location.hash.split("#")[2]
      }
    },

    methods: {
      handleClick(tab, event) {
        location.hash = this.$route.path + "#" + tab.name;
        if(tab.index == 3) {
          this.$refs.fourthMethod.getTicketRule();
        }
      }
    }
  }
</script>

<style scoped>
  .parking_ticket {
    padding: 10px;
    height: calc(100vh - 84px);
  }

  /deep/ .el-tabs__content{
    height: calc(100% - 50px);
  }




</style>
